package cn.kill.stockservice.controller;

import cn.kill.stockservice.common.Const;
import cn.kill.stockservice.service.StockService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 源码学院只为培养优秀的bat程序员而生
 *
 * @author 学员张在成
 * @data 2021/6/2
 */
@RestController
@RequestMapping("/stock")
@Slf4j
public class StockController {

        @Autowired
        private StockService stockService;

        @Autowired
        private StringRedisTemplate redisTemplate;

        @RequestMapping("/saveProduct")
        public  String  saveProduct(){
              stockService.saveStock();
              return "保存商品成功";
        }

        @RequestMapping("/delStock")
        public  String  delStock(){

            stockService.delStock();
            return "endSetnx";
        }

        @RequestMapping("/delStockRedssion")
        public  String  delStockRedssion(){
            stockService.delStockRedssion();
            return "endRedisson";
        }


        //删除key
        @RequestMapping("/delKey")
        public  String  delKey(){
            redisTemplate.delete(Const.key);
            return "删除key成功";
        }
}
